
int connect_to(const char* host_name)
{
	sockaddr_in serv_addr;
	int portno = 6565;
	int sockfd = socket(AF_INET, SOCK_STREAM, 0);

	if (sockfd < 0) {
		std::cerr << "Error opening socket" << std::endl;
		return -1;
	}
	memset(&serv_addr, 0, sizeof(serv_addr));
	serv_addr.sin_family = AF_INET;
	inet_pton(AF_INET, h_name, &serv_addr.sin_addr);
	serv_addr.sin_port = htons(portno);

	if(connect(sockfd, (sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
		std::cerr << "ERROR connecting" << std::endl;
		return -1;
	}
	return sockfd;
}
